package com.weita.lightfood.service;


import com.weita.lightfood.model.dao.LabelDao;
import com.weita.lightfood.model.entity.Label;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author IT_Monster at 2019/04/25 18:53.
 * 标签
 */
@Service
public class LabelService {
    @Autowired
    private LabelDao labelDao;

    /**
     * 获取所有标签
     * @return
     * @throws Exception
     */
    public List<Label> getAll() throws Exception {
        return labelDao.getAll();
    }



    /**
     * 通过标签名获取标签id
     * @param name
     * @return
     */
    public int getLabelIdByName(String name) {

        int labelId = -1;
        try {
            labelId = labelDao.getLabelIdByName(name);
            return labelId;
        } catch (Exception e) {
            System.out.println("标签名："+name+"，没找到");
        }
        return labelId;
    }
}
